<?php

class Default_ContactController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    	$this->_model = new Default_Model_DbTable_Contact();
    }

    public function indexAction()
    {
        // action body
    	$validator = new Zend_Validate();
    	if($this->getRequest()->isPost()){
    		$hoten = $this->_getParam("hoten");
    		$mess = $this->_getParam("message");
    		$date = date("Y-m-d");
    		$email = $this->_getParam("email");
    		if($validator->is($email, "EmailAddress")){
    			$this->_model->addContact($email, null, null, $hoten, $mess, $date, 1);
    			$this->_redirect("default/contact");
    			$this->view->errEmail = "Gửi Ý Kiến Thành Công!";
    		}else {
    			//$this->_redirect("default/contact");
    			$this->view->errEmail = "Sai định dạng email";
    		}
    	}
    }
    
}

